package com.study.crypto.basic.controller;

import com.study.crypto.basic.dto.RequestRandomDto;
import com.study.crypto.basic.dto.ResponseRandomDto;
import com.study.crypto.basic.dto.ca.*;
import com.study.crypto.basic.dto.ca.base.RequestCaDto;
import com.study.crypto.basic.service.CertificateIssuerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 证书签发控制器
 * @author Songjin
 * @since 2021-01-03 11:12
 */
@Slf4j
@RestController
@RequestMapping(value = "/issue")
public class CertificateIssuerController {
    
    @Autowired
    private CertificateIssuerService certificateIssuerService;

    /**
     * 获取随机数
     * @param request 请求数据
     * @return ResponseRandomDto
     */
    @PostMapping(value = "/applyServiceRandom")
    public ResponseRandomDto applyServiceRandom(@Valid @RequestBody RequestRandomDto request) {
        // return certificateIssuerService.applyServiceRandom(request);
        return null;
    }

    /**
     * 证书申请请求，单证，只有签名证书
     * @param request 请求数据
     * @return ResponseSealCertDto
     */
    @PostMapping(value = "/single/applySealCert")
    public ResponseCheckResultSealCertDto applySingleCert(@Valid @RequestBody RequestSealCertDistinctNameDto request) throws Exception {
        // return certificateIssuerService.applySingleCert(request);
        return null;
    }
    
    /**
     * 证书申请请求
     * @param request 请求数据
     * @return ResponseSealCertDto
     */
    @PostMapping(value = "/double/applySealCert")
    public ResponseSealCertDto applySealCert(@Valid @RequestBody RequestSealCertDto request) throws Exception {
        // return certificateIssuerService.applySealCert(request);
        return null;
    }
    
    /**
     * 使用taskId查询下载证书
     * @param request 请求数据
     * @return ResponseSealCertDto
     */
    @PostMapping(value = "/double/checkResult")
    public ResponseCheckResultSealCertDto checkResult(@Valid @Validated(RequestCaDto.SealCert.class) @RequestBody RequestCheckResultDto request) throws Exception {
        // return certificateIssuerService.checkResult(request);
        return null;
    }
    
}














